<%@ page language="java" contentType="text/html; charset=UTF-8" 
 pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <link rel="stylesheet" type="text/css" href="<%=basePath%>static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="<%=basePath%>static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="<%=basePath%>lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="<%=basePath%>static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="<%=basePath%>static/h-ui.admin/css/style.css" />
<title>品牌表的操作</title>
</head>
<style type="text/css">
.box{
position:relative;
padding-bootom:10px;
width:600px;
height:300px;
margin:auto;
overflow:auto;

}



td {
	width: 173px;
	height: 30px;
	line-height: 30px;
	font-size: "16px";
	text-align:center;
	border:1px solid #ddd;
}
.content{
position:absolute;
padding-top:20px;
width:400px;
margin-left:60px;
}
.tab_css{
border:1px solid #ddd;

}
.btn_css:hover{
 cursor:pointer;
 
}
</style>
<body>
<div class="box">
<div class="content">
<table class="tab_css" border="1" cellpadding="0" cellspacing="1">
<tr>
<td width="30">id</td>
<td width="60">品牌名称</td>
<td width="30">操作</td>
</tr>
<c:forEach items="${ brandlist}"  var ="brand">
<tr>
 <td width="30">${brand.pid }</td>
 <td width="60">${brand.brandname }</td>
 <td width="30"><button class="btn_css" title="删除" onclick="deletebrand(this,${brand.pid })"><i class="Hui-iconfont">&#xe6e2;</i></button></td>
 </tr>
 </c:forEach>

</table>
</div>
</div>
<script src="<%=basePath%>lib/jquery/1.9.1/jquery.min.js"
	type="text/javascript"></script>
<script type="text/javascript">
//检测品牌下是否存在型号 若存在则不能删除 否则可以删除
function deletebrand(obj,pid){
	$.ajax({
		url:"checkModelsExsit",
	     data:{
	    	 pid:pid
	     },
	     type:"post",
	     dataType:"json",
		success:function(data){
			
			if(data.rs){
			$.ajax({
				url:"deletebrand",
			     data:{
			    	 pid:pid
			     },
			     type:"post",
			     dataType:"json",
				success:function(){
					$(obj).parents("tr").remove();
					layer.msg("删除成功！");
				}
				
			});
			
			}else{
			alert("该品牌已经存在商品 不能删除");	
				
			}
			
		}
		
	});
	
	
	
	
	
}

</script>
</body>
</html>